/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
"use strict";


class Introspector {
    constructor() {
        this.currentResult = [];
        this.results = [];
    }
    start(tree) {
        this.tree = tree;
        this.currentResult = [];
    }
    end() {
        const result = this.currentResult.pop();
        if (result) {
            this.results.push(result);
        }
        delete this.tree;
        this.currentResult = [];
    }
    push(node, result, blackboard) {
        this.currentResult.push(this._toResult(node, result, blackboard));
    }
    wrapLast(numResults, node, result, blackboard) {
        const children = this.currentResult.splice(this.currentResult.length - numResults, numResults);
        // this.currentResult.push({this._toResult(node, result, blackboard), children });
        // this.currentResult.push({ ...this._toResult(node, result, blackboard), children });
    }
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    _toResult(node, result, _blackboard) {
        // return { ...(node.name ? { name: node.name } : {}), result };
    }
    reset() {
        this.results = [];
    }
    get lastResult() {
        if (this.results.length === 0) {
            return null;
        }
        return this.results[this.results.length - 1];
    }
}
// exports.default = Introspector;
export { Introspector  }